﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crosland.Automotriz.Core;
using System.Data.SqlClient;
namespace Crosland.Automotriz.Data.Dao.Linq
{
    public class clsTd_Canal_DistribDAO
    {

        private AutomotrizEntities ContextoDeObjs = new AutomotrizEntities();

        public List<TD_CANAL_DISTRIB> lista(){

            List<TD_CANAL_DISTRIB> list = new List<TD_CANAL_DISTRIB>();

            try
            {
                var q = from c in ContextoDeObjs.TD_CANAL_DISTRIB
                        orderby c.DES_CANAL_DISTRIB
                        select c;

                list = q.ToList();

            }
            catch{}


            return list;
        }

        public IEnumerable<TD_CANAL_DISTRIB> ListarCanalxOrganizacion(int ID_ORG_VTA)
        {
            var p = new object[] { new SqlParameter("@ID_ORG_VTA", ID_ORG_VTA) };
            var resultado = ContextoDeObjs.ExecuteStoreQuery<TD_CANAL_DISTRIB>("exec USP_CANAL_x_ORGANIZACION_LISTAR @ID_ORG_VTA", p).AsQueryable().ToList();
            return resultado;
        }
        public IEnumerable<TD_CANAL_DISTRIB> ListarCanalxOrg(int ID_ORG_VTA)
        {
            var p = new object[] { new SqlParameter("@ID_ORG_VTA", ID_ORG_VTA) };
            var resultado = ContextoDeObjs.ExecuteStoreQuery<TD_CANAL_DISTRIB>("exec USP_CANAL_x_ORG_LISTAR @ID_ORG_VTA", p).AsQueryable().ToList();
            return resultado;
        }

        //

        public IEnumerable<TD_CANAL_DISTRIB> ListarCanalxOrganizacionClienteVendedor(int ID_ORG_VTA)
        {
            var p = new object[] { new SqlParameter("@ID_ORG_VTA", ID_ORG_VTA) };
            var resultado = ContextoDeObjs.ExecuteStoreQuery<TD_CANAL_DISTRIB>("exec USP_CANAL_x_ORGANIZACION_CLIENTE_VENDEDOR_LISTAR @ID_ORG_VTA", p).AsQueryable().ToList();
            return resultado;
        }
    }
}
